package 贪心;

public class LeetCode122_买卖股票的最佳时机 {
    public int maxProfit(int[] prices) {
        int profit = 0;
        for(int i = 1; i < prices.length; ++i) {
            //前一天比他低就在前一天买入，今天卖出
            if(prices[i] > prices[i-1]) {
                profit += prices[i] - prices[i-1];
            }
        }
        return profit;
    }
}
